package sk.fiit.vppj.eventmanager.data;

/**
 * Data class, which represents user role Participant. Extends class User. The class is immutable.
 * 
 * @author Marek
 * 
 */
public final class Participant extends User {

	public Participant(int id) {
		super( id, "participant" );
	}

	public Project getProject() {
		return new Project( Integer.parseInt( data.get( "project_id" ).toString() ) );
	}

	/**
	 * Method return Organization to which this participant belongs
	 * 
	 * @return instance of Organization
	 */
	public Organization getOrganization() {
		return new Organization( Integer.parseInt( data.get( "organization_id" ).toString() ) );
	}

	public Supervisor getSupervisor() {
		int id = Integer.parseInt( data.get( "supervisor_id" ).toString() );
		if( id == 0 ) {
			return null;
		}
		return new Supervisor( id );
	}

	public boolean isLeader() {
		if( Integer.parseInt( data.get( "supervisor_id" ).toString() ) > 0 ) {
			return true;
		}
		return false;

	}
}
